package com.jgd.rsa.controller;

import com.jgd.rsa.util.SignSha1AndRsaUtils;
import org.springframework.web.bind.annotation.*;

import java.net.URLDecoder;
import java.util.Map;

@RestController
@RequestMapping("/sign")
public class SignController {

    private final static String PRIVATE_KEY = "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBALuKQDw12zlhGt5C\n" +
            "eC3Kh37vSay5dmMnnLv45d02LaOxHW7bOclSA9gfNLx9kapHQ9CEOZ/Bv09aI2ng\n" +
            "1DbUf3GxfAwcD03974fyZcZVbNvNoprbZIezxwEXe4bj8lWiZg29Ck2NAO7gLndJ\n" +
            "RYbEHgI1JTkjsmob/xICFmL3FrJbAgMBAAECgYBs0VRiW3Gfwqt/aZwoHcsvKRNb\n" +
            "yKVb9WEpZMuj5srmn1+Psl6+ZPtcDQdhk47Q+dbsh7yT6Szjk07XIaChS/3B8SHg\n" +
            "V76Sa9vxz8nwWE0zO/ScjY7VXd4qMe7swQULRKCvzD9KYCdcd69FuuFC2V9AZxFz\n" +
            "ropPKvkKt3Gq8nZuIQJBAONSmjRwaD1WLvL8te/kFPgQPBQOgzOw5Kxu+tuLziX/\n" +
            "TPin5qZ7ql8dyjj6U3sAPStX31bpjrZoItV+5TaE9XECQQDTMt3bGzsSUSe/bIKM\n" +
            "7vBWG6WedNLw4OFUiURpKyFemwgDUKimRYY3KY/I7xnSGXudxhastNZ8vV6j7app\n" +
            "bU6LAkEAqhOeLge/5cw6WjA6yx3BlotG99aX0S/TFzP9Wg9ykDk/1HaCeiLiKEH4\n" +
            "j8KyfL+EBI69GaCq1sx463UCd1To8QJAerdTsbxg1oPRVKj4MmujumTWFvxKlSwV\n" +
            "wckAtxsYiKAMR+DWHcbH9cVwhpBnsGyeJ06yXie1eUWPeDDgk+GvgQJAGGpAQtev\n" +
            "ThdjmAG1AuD7txf3uvL3BRvuEIXeDYmxr+hwrApLgbUH41h+xlEefHwuOpyhWvcm\n" +
            "wLSnL1mXGC5hXg=="; // 请替换为你的私钥

    @GetMapping("/encrypt")
    public String encrypt() throws Exception {
        String checkValues = "123";

        checkValues = URLDecoder.decode(checkValues, "UTF-8").replace(" ", "+");
        return SignSha1AndRsaUtils.rsaEncrypt(checkValues, PRIVATE_KEY);
    }
}
